#pragma once

#include "TrTypes.h"
#include "TrSingleton.h"
#include <spdlog/spdlog.h>

#ifndef BUILD_STATIC
# if defined(TRLOGGER_LIB)
#  define TRLOGGER_EXPORT __declspec(dllexport)
# else
#  define  TRLOGGER_EXPORT __declspec(dllimport)
# endif
#else
# define  TRLOGGER_EXPORT
#endif

constexpr auto DEFAULT_LOG_PATTERN = "[%Y%m%d %H:%M:%S.%e][%^%-5l%$] %v";
typedef std::shared_ptr<spdlog::logger> SpdLoggerPtr;


class TRLOGGER_EXPORT TrLogger : public TrSingleton<TrLogger>
{
    friend class TrSingleton<TrLogger>;
public:
    TrLogger(const TrLogger&) = delete;
    TrLogger& operator =(const TrLogger&) = delete;
	static SpdLoggerPtr create(const char* logger, spdlog::level::level_enum level);
	static SpdLoggerPtr get(const char* logger);

	template<typename... Args>
	static void trace(const char* format, const Args& ...args);
	static void trace(const char* msg);

	template<typename... Args>
	static void debug(const char* format, const Args& ...args);
	static void debug(const char* msg);

	template<typename... Args>
	static void info(const char* format, const Args& ...args);
	static void info(const char* msg);

	template<typename... Args>
	static void warn(const char* format, const Args& ...args);
	static void warn(const char* msg);

	template<typename... Args>
	static void error(const char* format, const Args& ...args);
	static void error(const char* msg);

	template<typename... Args>
	static void fatal(const char* format, const Args& ...args);
	static void fatal(const char* msg);
private:
    TrLogger();

};
